home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / gui / precog2_1.lha / Precognition2_1 / src / src.lha / Library / VSlider.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-16  |  3.7 KB  |  161 lines

  1. /* ==========================================================================
  2. **
  3. **                         VSlider.c
  4. ** ©1991 WILLISoft
  5. **
  6. ** ==========================================================================
  7. */
  8.  
  9. #include <stdio.h>
  10. #include "minmax.h"
  11. #include "Vslider.h"
  12. #include "VSliderClass.h"
  13. #ifndef __GNUC__
  14. #include <clib/exec_protos.h>
  15. #include <clib/intuition_protos.h>
  16. #include <clib/graphics_protos.h>
  17. #endif
  18. #ifdef __GNUC__
  19. #include <proto/exec.h>
  20. #include <proto/intuition.h>
  21. #include <proto/graphics.h>
  22. #endif
  23. #ifdef __SASC
  24. #include <proto/exec.h>
  25. #include <proto/intuition.h>
  26. #include <proto/graphics.h>
  27. #endif
  28. #include "amigamem.h"
  29.  
  30.  
  31.    tPoint VSlider_AskSize( VSlider *self,
  32.                            PIXELS  Width,
  33.                            PIXELS  Height )
  34.    {
  35.       tPoint size;
  36.  
  37.       size.x = MAX( Width,  10 );
  38.       size.y = MAX( Height, 20 );
  39.  
  40.       return size;
  41.    }
  42.  
  43.  
  44.  
  45.    LONG VSlider_Value( VSlider *self )
  46.    {
  47.       return self->Prop.VertPot;
  48.    }
  49.  
  50.  
  51.    USHORT VSlider_KnobSize( VSlider *self )
  52.    {
  53.       return self->Prop.VertBody;
  54.    }
  55.  
  56.  
  57.    LONG VSlider_SetValue( VSlider *self, LONG value )
  58.    {
  59.       struct pcgWindow *window;
  60.       struct PropInfo   propinfo;
  61.       USHORT position;
  62.  
  63.       position = value;
  64.       propinfo = self->Prop;
  65.  
  66.       if( ( window = InteractorWindow( (Interactor *)self ) ) &&
  67.           ( window->Window ) )
  68.       {
  69.          NewModifyProp( &self->eg.g, window->Window, NULL, propinfo.Flags,
  70.             propinfo.HorizPot,  position,
  71.             propinfo.HorizBody, propinfo.VertBody,
  72.             1 );
  73.       }
  74.       else
  75.       {
  76.          self->Prop.VertPot  = position;
  77.       }
  78.  
  79.       return position;
  80.    }
  81.  
  82.  
  83.    USHORT VSlider_SetKnobSize( VSlider *self, USHORT knobsize )
  84.    {
  85.       struct pcgWindow *window;
  86.       struct PropInfo   propinfo;
  87.  
  88.       propinfo = self->Prop;
  89.  
  90.       if( ( window = InteractorWindow( (Interactor *)self ) ) &&
  91.           ( window->Window ) )
  92.       {
  93.          NewModifyProp( &self->eg.g, window->Window, NULL, propinfo.Flags,
  94.             propinfo.HorizPot,  propinfo.VertPot,
  95.             propinfo.HorizBody, knobsize,
  96.             1 );
  97.       }
  98.       else
  99.       {
  100.          self->Prop.VertBody = knobsize;
  101.       }
  102.  
  103.       return knobsize;
  104.    }
  105.  
  106.  
  107.  
  108.    BOOL VSlider_elaborated = FALSE;
  109.  
  110.    struct PositionerClass VSlider_Class;
  111.  
  112.    void VSliderClass_Init( struct PositionerClass *class )
  113.    {
  114.       SliderClass_Init( class );
  115.       class->isa         = SliderClass();
  116.       class->ClassName   = "VSlider";
  117.       class->AskSize     = (Point(*)(GraphicObject *, PIXELS, PIXELS))VSlider_AskSize;
  118.       class->SetValue    = (LONG(*)(Valuator *, LONG))VSlider_SetValue;
  119.       class->Value       = (LONG(*)(Valuator *))VSlider_Value;
  120.       class->SetKnobSize = (USHORT(*)(Positioner *, USHORT))VSlider_SetKnobSize;
  121.       class->KnobSize    = (USHORT(*)(Positioner *))VSlider_KnobSize;
  122.  
  123.    }
  124.  
  125.  
  126.    struct PositionerClass *VSliderClass( void )
  127.    {
  128.       if( ! VSlider_elaborated )
  129.       {
  130.          VSliderClass_Init( &VSlider_Class );
  131.          VSlider_elaborated = TRUE;
  132.       }
  133.  
  134.       return &VSlider_Class;
  135.    }
  136.  
  137.  
  138.    void VSlider_Init( VSlider    *self,
  139.                       PIXELS     LeftEdge,
  140.                       PIXELS     TopEdge,
  141.                       PIXELS     Width,
  142.                       PIXELS     Height,
  143.                       pcg_3DPens Pens,
  144.                       char      *label )
  145.    {
  146.       Point size;
  147.  
  148.       size = VSlider_AskSize( self, Width, Height );
  149.  
  150.       Slider_Init( self, LeftEdge, TopEdge, size.x, size.y, Pens );
  151.       SetTitle( (GraphicObject *)self, label );
  152.       SetTextAlignment( (GraphicObject *)self, tx_XCENTER | tx_BOTTOM | tx_OUTSIDE, STD_XPAD, STD_YPAD );
  153.  
  154.       self->eg.isa        = VSliderClass();
  155.       self->Prop.Flags   |= FREEVERT;
  156.       self->Prop.VertBody = 0x4000;
  157.    }
  158.  
  159.  
  160.  
  161.